package com.bjpowernode.crm.workbench.web.controller;

import com.bjpowernode.crm.commons.contants.Contants;
import com.bjpowernode.crm.commons.domain.ReturnObject;
import com.bjpowernode.crm.commons.utils.DateUtils;
import com.bjpowernode.crm.commons.utils.UUIDUtils;
import com.bjpowernode.crm.settings.domain.User;
import com.bjpowernode.crm.workbench.domain.ActivityRemark;
import com.bjpowernode.crm.workbench.service.ActivityRemarkService;
import lombok.Getter;
import lombok.Setter;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * 市场备注控制器
 *
 * @author 刘逸晖
 */
@Getter
@Setter
@RequestMapping
public class ActivityRemarkController {

    /**
     * 处理市场备注相关业务
     */
    private ActivityRemarkService activityRemarkService;

    /**
     * 保存市场活动备注
     *
     * @param activityRemark 预保存的市场活动备注
     * @param session        http 会话
     * @return 保存结果
     */
    @PostMapping("/workbench/activity/saveCreateActivityRemark.do")
    @ResponseBody
    public ReturnObject saveCreateActivityRemark(ActivityRemark activityRemark, HttpSession session) {
        this.activityRemarkService.saveActivityRemark(activityRemark, session);

        ReturnObject returnObject = new ReturnObject();
        returnObject.setCode(Contants.RETURN_OBJECT_CODE_SUCCESS);
        returnObject.setRetData(activityRemark);
        returnObject.setMessage("恭喜，添加市场活动备注成功");

        return returnObject;
    }

    /**
     * 删除市场活动备注
     *
     * @param id 市场活动备注的 id
     * @return 删除结果
     */
    @PostMapping("/workbench/activity/deleteActivityRemarkById.do")
    @ResponseBody
    public ReturnObject deleteActivityRemarkById(String id) {
        this.activityRemarkService.deleteActivityRemarkById(id);

        ReturnObject returnObject = new ReturnObject();
        returnObject.setMessage("恭喜，删除市场活动备注成功");
        returnObject.setCode(Contants.RETURN_OBJECT_CODE_SUCCESS);

        return returnObject;
    }

    /**
     * 编辑市场活动备注
     *
     * @param activityRemark 市场活动备注 id 极其新内容
     * @param session        http 会话
     * @return 编辑结果
     */
    @PostMapping("/workbench/activity/saveEditActivityRemark.do")
    @ResponseBody
    public ReturnObject saveEditActivityRemark(ActivityRemark activityRemark, HttpSession session) {
        this.activityRemarkService.editActivityRemarkById(activityRemark, session);

        ReturnObject returnObject = new ReturnObject();
        returnObject.setCode(Contants.RETURN_OBJECT_CODE_SUCCESS);
        returnObject.setMessage("恭喜，编辑市场活动备注成功");
        returnObject.setRetData(activityRemark);

        return returnObject;
    }

}
